package com.woniuxy.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.woniuxy.service.CityService;

/**
 * Servlet implementation class CityServlet
 */
@WebServlet("/CityServlet")
public class CityServlet extends HttpServlet {
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		System.out.println("111");
		req.setCharacterEncoding("utf-8");
		resp.setContentType("text/html; charset=UTF-8");
		int pid =Integer.parseInt( req.getParameter("pid"));
		new ObjectMapper().writeValue(resp.getWriter(), new CityService().getAllCitys(pid));
	}

}
